package Reflect.test3;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class Test {
    public static void main(String[] args) throws Exception{
        Class<?> aClass = Class.forName("Reflect.Person");
        Object object = aClass.newInstance();

        Method[] methods = aClass.getDeclaredMethods();
        System.out.println(methods.length);

        for (Method m : methods){
            int aPublic = Modifier.PUBLIC;
            boolean flag = (m.getParameterCount() == 0);
//            m.setAccessible(true);
            if(flag==true && m.getModifiers()==aPublic){
                m.invoke(object);
            }
        }


    }
}
